# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=felix
pkgver=2.13.0
pkgrel=0
pkgdesc="Simple TUI file manager with vim-like key mapping"
url="https://kyoheiu.dev/felix/"
# s390x: nix crate doesn't build yet
# riscv64: tests fail
arch="all !s390x !riscv64"
license="MIT"
makedepends="
	bzip2-dev
	cargo
	cargo-auditable
	libgit2-dev
	oniguruma-dev
	zlib-ng-dev
	zstd-dev
	"
checkdepends="zoxide"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/kyoheiu/felix/archive/refs/tags/v$pkgver.tar.gz
	use-system-libs.patch
	"

export RUSTONIG_DYNAMIC_LIBONIG=1

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libs
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		git2 = { rustc-link-lib = ["git2"] }
		z-ng = { rustc-link-lib = ["z-ng"], rustc-cfg = ["zng"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/fx -t "$pkgdir"/usr/bin/
}

sha512sums="
545ccf207abbc606ea428edc363067c1976b34d54a0a175bb1cc60406b87b581ae68b1445735655e2ef24ad49a357b6e66f735f52e197f5a55b0bb8998c4ba89  felix-2.13.0.tar.gz
ef74e6a6d7e7ba4438e1fab7e3f9aee61c718b5873acc4c693dd5a02af9325073eb4cd42e5e5b2337698d7e048829dbf56d3e55adeadfcc969a4ffbc2d7811c8  use-system-libs.patch
"
